<?php

namespace App\Listeners\Subscriber;

use Illuminate\Events\Dispatcher;
use App\Events\Position\DeletedEvent;

class PostionEventSubscriber
{
	/**
	 * 删除岗位信息时触发
	 *
	 * Date: 2018/5/30
	 * @author George
	 * @param DeletedEvent $event
	 */
	public function onDeleted(DeletedEvent $event)
	{
		$event->position->permissions()->detach();
	}

	/**
	 * 为订阅者注册监听器
	 *
	 * Date: 23/03/2018
	 * @author George
	 * @param Dispatcher $events
	 */
	public function subscribe(Dispatcher $events)
	{
		$events->listen(
			'App\Events\Position\DeletedEvent',
			'App\Listeners\Subscriber\PostionEventSubscriber@onDeleted'
		);
	}
}
